/***************************************************************************
 *   Copyleft 2006-2007 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>			                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __VECTOR2D_H__
#define __VECTOR2D_H__

#include <math.h>
#include "../../Types/Types.h"
#include "MathConstants.h"


class Vector2D {
public:
	union {
		struct {
			cFloat mValues[2];
		};
		struct {
			cFloat mX;
			cFloat mY;
		};
	};

	/**************************************************************
    * Constructors                                                *
    ***************************************************************/
	Vector2D(): mX(0.0f), mY(0.0f) { }
	Vector2D(cFloat fX, cFloat fY): mX(fX), mY(fY) { }
	Vector2D(const Vector2D& vect);

 	/**************************************************************
    * Operators                                                   *
    ***************************************************************/
	Vector2D& operator+=(const Vector2D& vectB);
	Vector2D& operator-=(const Vector2D& vectB);
	Vector2D operator-() const;
	Vector2D& operator*=(const Vector2D& vectB);
	Vector2D& operator*=(const cFloat fFactor);

	/**************************************************************
    * Friend functions                                            *
    ***************************************************************/
	friend Vector2D operator+(const Vector2D& vectA, const Vector2D& vectB);
	friend Vector2D operator-(const Vector2D& vectA, const Vector2D& vectB);
	friend Vector2D operator*(const Vector2D& vectA, const Vector2D& vectB);
	friend Vector2D operator*(const Vector2D& vectA, const cFloat fFactor);

	/**************************************************************
	* Math functions                                              *
	***************************************************************/
	cVoid Set(cFloat fX, cFloat fY);
	cFloat Length() const;
	cFloat SqrtLength() const;
	cFloat DotProduct(const Vector2D& vectB);
};
#endif // __VECTOR2D_H__
